home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / prefixHierarchy.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.9 KB  |  128 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. // Copyright (C) 1997-1998 Alias|Wavefront,
  18. // a division of Silicon Graphics Limited.
  19. //
  20. // The information in this file is provided for the exclusive use of the
  21. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  22. // and incorporate this code into other products for purposes authorized
  23. // by the Alias|Wavefront license agreement, without fee.
  24. //
  25. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  26. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  27. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  28. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  29. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  30. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  31. // PERFORMANCE OF THIS SOFTWARE.
  32. //
  33. //
  34. // Alias|Wavefront Script File
  35. // MODIFY THIS AT YOUR OWN RISK
  36. //
  37. // Creation Date:      17 December 1998
  38. // Original Author:    jb
  39. // Rewritten by:    stefand
  40. //
  41. //  Procedure Name:
  42. //      prefixHierarchy
  43. //
  44. //  Description:
  45. //        Brings up a prompt dialog to ask the user for a prefix
  46. //        to add to the names of a complete hierarchy, starting at the 
  47. //        selected nodes, and traversing the transform nodes downwards.
  48. //
  49. //        Note: this does no checking for 'illegal' characters!  This
  50. //        should be added.
  51. //
  52. //  Input Arguments:
  53. //        None.
  54. //
  55. //  Return Value:
  56. //      None.
  57. //
  58.  
  59.  
  60. // rename a transform node by giving it a prefix
  61. // recurses to all children
  62. proc prefixNode(string $prefix, string $node)
  63. {    
  64.     // check if it is a transform or derived from transform.
  65.     // We don't rename shapes since they will likely be renamed
  66.     // when we renamed their parent transform.
  67.     //
  68.     string $isType[]    = `ls -type transform $node`;
  69.     if (size($isType) > 0 ) {
  70.  
  71.         // extract the name of this node from its full path
  72.         //
  73.         string $nodeName = `substitute ".*|" $node ""`;
  74.  
  75.         // rename this node
  76.         //
  77.         string $newName = `rename $node ( $prefix + $nodeName )`;
  78.     }
  79. }
  80.  
  81.  
  82. global proc prefixHierarchy( )
  83. {
  84.     string $result = `promptDialog
  85.         -title "Prefix Hierarchy"
  86.         -message "Enter Prefix: "
  87.         -text "prefix_"
  88.         -button "OK"
  89.         -button "Cancel"
  90.         -defaultButton "OK"
  91.         -cancelButton "Cancel"
  92.         -dismissString "Cancel"`;
  93.  
  94.     // If the result was "OK", then proceed
  95.     //
  96.     if ( $result == "OK" ) {
  97.  
  98.         // Get the prefix the user entered
  99.         //
  100.         string $prefix = `promptDialog -q`;
  101.  
  102.         // Get a list of all descendents (The nodes are ordered from
  103.         // leaf to root
  104.         //    
  105.         string $currentNodes[] = eval("listRelatives -pa -ad `ls -sl -l`");
  106.     
  107.         // add the prefix to each descendent node
  108.         //
  109.         if ( size( $currentNodes ) > 0 ) {
  110.             for( $i=0; $i < size( $currentNodes ); $i++ ) {
  111.                 prefixNode( $prefix, $currentNodes[$i] );
  112.             }
  113.         }
  114.  
  115.         // get a list of nodes on the list
  116.         $currentNodes = `ls -sl -l`;
  117.     
  118.         // add the prefix to each node on the active list
  119.         //
  120.         if ( size( $currentNodes ) > 0 ) {
  121.             for( $i=0; $i < size( $currentNodes ); $i++ ) {
  122.                 prefixNode( $prefix, $currentNodes[$i] );
  123.             }
  124.         }
  125.     }
  126. }
  127.  
  128.